<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style>
    	/* body{
    		
    	} */
    </style>
</head>
<body>
	 <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
         <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            选择子设备
        </div> 
    </header> 
	<div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-list-in" id="tbodyHtml">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
	apiready = function(){
		//var equipCode = api.pageParam.equipCode;
		var SRequipCode = api.pageParam.SRequipCode;
		getEquipTaskByEquipCode(SRequipCode);
	};
	
	function getEquipTaskByEquipCode(SRequipCode)
	{
		//alert("查询检修项");
		var serverUrl = localStorage.getItem('serverUrl');
		var url = serverUrl + "/app/getSonEquip";
		var un = localStorage.getItem('un');
		
		var params = new Object();
		params.url = url;
		params.method = 'post';
		params.dataType = 'json';
		params.returnAll = 'false';
		params.timeout = 60;
		
		var data = {
			values: { 
				un: un,
	            url: url,
	            SRequipCode: SRequipCode
	        }
		};
		
		// ajaxForData(params,data,false,function(ret, err){
		// 	var myobj = eval("("+ret.data+")");		
		// 	$("#equipTaskListUl").children().remove();
		// 	$("#equipTaskHCListUl").children().remove();
	    //     for (var i = 0; i < myobj.length; i++) {		       		
		// 		$("#equipTaskListUl").append("<li class='aui-list-view-cell'><a onclick='setEquipTask(\""+myobj[i].taskId+"\",\"" + myobj[i].taskCode + "\",\"" + myobj[i].equipId + "\",\"" + myobj[i].SRequipCode + "\",\"" + myobj[i].actualBeginDate + "\",\"" + myobj[i].actualEndDate + "\",\"" + myobj[i].taskResult + "\");' > "+ myobj[i].taskCode +"---"+ myobj[i].chkModeName +"</a></li>");
		// 	}
		// }); 
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    var list = myobj.list;
                    var html = "";
                    // $("#equipTaskListUl").children().remove();
		 	        // $("#equipTaskHCListUl").children().remove();
                    //遍历
//					alert(list)
					if(list != undefined && list != ""){
						for (var i = 0; i < list.length; i++) {
                        html += "<li class='aui-list-view-cell'><a onclick='setSonEquipTask(\""+list[i].sysid+"\",\"" + list[i].equipCode + "\",\"" + list[i].equipName + "\");' > "+ list[i].equipName +"</a></li>";
                    }
					}

                    $api.html($api.byId("tbodyHtml"), html);

                } else if (myobj.code == '1') {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
	}
	

	function setSonEquipTask(sysid,equipCode,equipName)
	{
		api.closeWin();
		
		api.execScript({
			// name : 'about2',
			// frameName : 'about-con',
            name : api.pageParam.name,
			script : 'setSonEquip("'+sysid+'","'+equipCode+'","'+equipName+'")'
		});
	}
	//返回按钮
    function closeWin() {
        api.closeWin({});
    }

</script>
</html>